<?php
class monitorController extends AdminController
{
    public function init()
    {
        $this->tableName='cron';
        parent::init();
    }
    public function indexAction()
    {
        $zym_8=$this->model->field('id,name,interval,lastruntime,status')->where(array('action'=>'cron.task.collect'))->order('status desc')->select();
        foreach ($zym_8 as &$zym_9) {
            if (C('cron_power')) {
                if ($zym_9['status']==0) {
                    $zym_9['info']='当前任务已经被禁用......';
                } else {
                    $zym_7=cache::get("cron_{$zym_9['id']}_status");
                    if ($zym_7=='run') {
                        $zym_5=trim(cache::get("cron_{$zym_9['id']}_novel"));
                        if ($zym_5) {
                            $zym_9['info']='正在更新《'.$zym_5.'》......';
                        } else {
                            $zym_9['info']='获取列表数据中......';
                        }
                    } else {
                        $zym_9['info']='本次执行完毕，等待下次运行,预计启动时间-'.date('H:i:s', $zym_9['lastruntime']+$zym_9['interval']);
                    }
                }
            } else {
                $zym_9['info']='主进程尚未开启';
            }
            $zym_6=cache::get("cron_{$zym_9['id']}_time");
            if ($zym_6) {
                $zym_9['starttime']=date('Y-m-d H:i:s', $zym_6);
                $zym_9['last']=time()-$zym_6;
            } else {
                $zym_9['starttime']='';
                $zym_9['last']=0;
            }
            $zym_9['lastruntime']=date('Y-m-d H:i:s', $zym_9['lastruntime']);
        }
        if (IS_AJAX) {
            $this->ajax(array('data'=>$zym_8,'now'=>date('Y-m-d H:i:s', $this->cache->get('cron_master_runtime'))));
        }
        $this->list=$zym_8;
        $this->display();
    }
}
